Method for statistical analysis of images for automatic white balance of color channel gains for image sensors

ABSTRACT

A process for performing white balancing of an image is performed by subdividing an image into a plurality of subframes, and then analyzing each subframe to determine if that subframe is predominantly monochromatic other than gray. If so, that subframe is excluded from the computation of the gain adjustments in the white balancing operation. As a result, the white balance process is performed using only the multicolored and/or gray subframes, thus allowing the overall white-balance of the image to be shifted only when a change in the color average is due to a change in the spectra of illumination, and not a presence of large monochromatic areas in the image.

FIELD OF THE INVENTION

The present invention relates to a method for adjusting the color gainsin an imaging system to compensate for the variations in illuminationspectra attributable to different illumination sources.

BACKGROUND OF THE INVENTION

The human eye and brain are capable of “white balancing.” If a persontakes a white card outside, it looks white. If he takes it inside andviews it under fluorescent lights, it looks white. When viewed under anincandescent light bulb, the card still looks white. Even when placedunder a yellow light bulb, within a few minutes, the card will lookwhite. With each of these light sources, the white card is reflecting adifferent color spectrum, but the brain is smart enough to make it lookwhite.

Obtaining the same result with a camera or other imaging device isharder. When the white card moves from light source to light source, animage sensor “sees” different colors under the different conditions.Consequently, when a digital camera is moved from outdoors (sunlight) toindoor fluorescent or incandescent light conditions, the color in theimage shifts. If the white card looks white when indoors, for example,it might look bluish outside. If it looks white under fluorescent light,it might look yellowish under an incandescent lamp.

One of the most challenging problems in color image processing isadjusting the color gains of the system to compensate for the variationsin the illumination spectra incident on the imaging sensor due to theillumination source, also known as white balance. This problem stemsfrom the fact that spectral emission curves of common sources ofillumination are significantly different from each other. For example,in accordance with Plank's law, the spectral energy curve of the sun isshifted towards the shorter wavelengths relative to the spectral energycurve of an incandescent light source. Therefore, the sun can beconsidered to be a “blue-rich” illuminator while an incandescent bulbcan be considered to be a “red-rich” illuminator. As a result, if thecolor processing settings are not adjusted, scenes illuminated by thesunlight produce “bluish” imagery, while scenes illuminated by anincandescent source appear “reddish”.

In order to compensate for changes in illumination spectra, the gains ofthe color processing systems and/or imager should be adjusted. Thisadjustment is usually performed to preserve the overall luminance(brightness) of the image. As a result of proper adjustment, gray/whiteareas of the image appear gray/white on the image-rendering device(hence the term “white balance”). In the absence of specific knowledgeof the spectra of the illumination source, this adjustment can beperformed based on inference of the spectra of illumination from ananalysis of the image itself.

The most commonly used approach to computing the proper adjustment tothe color channel gains is based on the premise that in complex imagesall colors are represented equally. Based on this assumption, the sumsof all red, green and blue components in the image should be equal (inother words, the image should average to gray). Following this approach,the overall (average over the entire image) luminance Y, and red(R_avg), green (G_avg) and blue (B_avg) components are evaluated. Thecolor gains (G_red, G_Green, G_blue) are then selected so thatY=G_red*R_avg=G_green*G_avg=G_blue*B_avg.

This conventional approach produces reasonable color rendition forimages containing a large number of objects of different colors or largegray areas, such as that shown in region “A” indicated in FIG. 1.However, if the image contains any large monochrome regions, such asthat shown in region “B” indicated in FIG. 1, the conventional approachfails. This is the case in many practical situations. Typical examplesof such images with a large area having only one color includelandscapes in which a significant portion of the image is occupied byeither blue sky or green vegetation. Other examples include close-upimages of people, wherein flesh tones occupy a significant portion ofthe image. Yet another example is a non-gray wall serving as abackground of the image.

In all of the above scenarios, the averages of the color components ofthe image would not be equal. An adjustment of the gains based on suchproportions would not produce a properly white-balanced image. In otherwords, the conventional approach to white balancing an image does notdistinguish between shifts in the spectra of illumination or thepresence of large monochromatic regions in the image.

BRIEF SUMMARY OF THE INVENTION

The present invention addresses the problems with the prior art approachby performing a statistical analysis of the image that distinguishesbetween effects on the color averages due to a change in the spectra ofillumination and those due to the presence of large monochromaticregions in the image.

Specifically, the method of the present invention subdivides an imageframe into a plurality of subframes, and each subframe is analyzed todetermine if that subframe is predominantly monochromatic other thangray or white. If so, that subframe is excluded from the computation ofthe gain adjustments. As a result, the white balance process isperformed using only the multicolored and/or gray subframes, thusallowing the overall white-balance of the image to be shifted only whena change in the color average is due to a change in the spectra ofillumination, and not a presence of large monochromatic areas in theimage.

Other features and advantages of the present invention will becomeapparent from the following description of the invention which refers tothe accompanying drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 demonstrates an image having large monochromatic areas and towhich the method of the present invention is applicable for a whitebalancing operation;

FIG. 2 illustrates the method of the present invention;

FIG. 3 is a processing flowchart for illustrating method of the presentinvention;

FIG. 4 is an illustration of an imaging apparatus incorporating acircuit for performing automatic white balance in accordance with themethod of the present invention; and

FIG. 5 is an illustration of a processing system communicating with animaging apparatus of the present invention.

DETAILED DESCRIPTION OF THE INVENTION

FIG. 3 illustrate a processing method which can be carried out by amicroprocessor or a microcontroller of an image sensor. In the methodaccording to the present invention, an image obtained from an imagingdevice such as an image sensor at processing segment 102 is subdividedinto a plurality of subframes as shown in FIG. 2 and indicated asprocessing segment 104 in FIG. 3. In the exemplary processing methodillustrated in FIG. 3, the image frame is divided into K subframes,wherein K is the number of subframes.

Each subframe is then individually analyzed to determine whether thegiven subframe includes multicolored or gray areas at processingsegments 108 and 110. At processing segment 106, before any subframesare analyzed, a counter variable C is set to 0 for keeping track of thenumber of subframes in the image frame that have been analyzed.

Each subframe is analyzed at processing segment 108 by first obtainingthe value of hue for each pixel in the subframe using Eqs. 1–10 asfollows:M=max(R,G,B)  (Eq. 1)¹m=min(R,G,B)  (Eq. 2)¹r=(M−G)/(M−m)  (Eq. 3)¹g=(M−G)/(M−m)  (Eq. 4)¹b=(M−B)/(M−m)  (Eq. 5)¹if R=M then Hue=60(b−g)  (Eq. 6)¹if G=M then Hue=60(2+r−b)  (Eq. 7)¹if B=M then Hue=60(4+g−r)  (Eq. 8)¹if Hue>360 then Hue=Hue−360  (Eq. 9)¹if Hue<0 then Hue=Hue+360  (Eq. 10)¹¹ Reference: Keith Jack, “Chapter 3, Color Spaces,” Video Demystified,pp. 50–51 (HighText 2d ed. 1996).

In the equations above, R, G and B are the signal levels for R, G and B,respectively, for each pixel, and M and m determine the highest andlowest values, respectively, of R, G and B. Thus, if R has the highestvalue, then the hue value of the pixel is calculated using Eq. 6. If Ghas the highest value, then the hue value of the pixel is calculatedusing Eq. 7. Similarly, if B has the highest value, then the hue valueof the pixel is calculated using Eq. 8.

Based on the hue values for each of the pixels, a mean hue iscalculated, and then the standard deviation of hue across each subframeis calculated using the difference between each hue value and the meanvalue as set forth in Eq. 11 below.σ² _(hue)=1/N·Σ(ΔHue_(i))²,  (Eq. 11)wherein N is the number of pixels in the subframe, andΔHue_(i)=Hue_(i);− Hue; if ΔHue_(i);>180 then ΔHue_(i)=360−ΔHue_(i)

For this calculation, any pixels at the saturation level for any or allof the color components in the image are not considered since they donot convey useful color information for white balance purposes. Forexample, a white pixel which results from all of the color componentsbeing at a saturated level are not considered in the deviancecalculation. However, white-appearing pixels which are simply a brightshade of grey are considered in the calculation.

Also, it is noted that gray colors are typically grayscale tonescomposed of very low levels of one or more of the color components. At apixel level, such gray areas in the image appear as multi-colored areasdue to spatial noise, which therefore creates very large deviations inhue values from pixel to pixel. This is very beneficial for thestability of the white balance algorithm, as color gain computationrequires the adjustment of gains so that the image averages to gray.

The standard deviation obtained in Eq. 11 is then compared against apredetermined threshold H_(th) at processing segment 110. Subframesstandard deviations of hue less than H_(th) are considered to bemonochromatic and are excluded from the statistics gathering processused to calculate the white balance of the image in processing segment112. For Eq. 11, the threshold of comparison H_(th) to determine if asubframe is monochromatic is approximately in the range of 10 to 40 for8-bit depths of pixel color, although this number may vary according tothe system parameters in the implementation of the invention.

Once a subframe has been analyzed at segments 108 and 110, and asubframe is excluded (segment 112) or not from use in a white balanceconnection, the counter variable is incremented by one at processingsegment 114 and then it is determined whether or not the number ofsubframes which have been processed is equal to K, the total number ofsubframes, at processing segment 116. If not, the process returns tosegment 108 to analyze the next subframe.

After the monochromatic subframes have been identified and excluded fromthe white balancing process in segment 112, the white balancing processmay be performed in processing segment 118 using the non-excludedsubframes in any known method or algorithm that effectuates theadjustment of the balance between the color components in the image inprocessing segment 118. For example, color balancing is typicallyperformed by summing each of the values for red, green and blue,respectively, and weighting the sums so that the three components areequal, whereupon each of the individual pixel datum is adjusted by theweighted value for the corresponding color component.

Alternative embodiments of the method of the present invention may beused in which the calculation of hue and its standard deviation for eachsubframe may be approximated with simpler schemes, to simplify hardwareimplementation.

In the embodiment discussed above, Eqs. 6–10 for calculating the huevalue of each pixel are based on the commonly used color wheelrepresentation of hue in the visible spectrum, wherein each color, orhue, is expressed as a value within the range of 0° to 360°. In onealternative embodiment of this invention, the range of hue is redefinedto have values along a scale of 0 to 96. The hue value determinations ofthis embodiment are executed at processing segment 108 using themodified Eqs. 12–16 below.if R=M then Hue=16(b−g)  (Eq. 12)if G=M then Hue=16(2+r−b)  (Eq. 13)if B=M then Hue=16(4+g−r)  (Eq. 14)if Hue>96 then Hue=Hue−96  (Eq. 15)if Hue<0 then Hue=Hue+96  (Eq. 16)

Although redefining the hue range in this manner results in a coarserevaluation of the hue value for each pixel, it does not modify thegeneral concept behind the present invention, but allows the analysis ofprocessing segment 108 to be performed with 6-bit wide hues and requiresonly 4 bits for the multiplication by 16 in Eqs. 12–14, instead of the 6bits needed for multiplication by 60 in Eqs. 6–8. Such modificationtherefore makes the computations more efficient.

In another embodiment of the present invention, the calculation of huevariances in the analysis of the subframes at processing segment 108uses sums of the absolute value of the differences between the currenthue and the mean hue, as set forth in Eq. 17, instead of the squares ofthe same as employed in Eq. 11.σ² _(hue)=1/N·Σ|ΔHue_(i)|,  (Eq.17)wherein N is the number of pixels in the subframe, andΔHue_(i)=Hue_(i);− Hue_(i) ; if ΔHue_(i);>48 then ΔHue_(i)=96−ΔHue_(i)

If σ² _(hue)>H_(th), then all the pixels in the subframe are determinedto be monochromatic at processing segment 110, and hence are excludedfrom the computation of the average color values of the image. In thisembodiment, preferable values for H_(th) are in the range from 3 to 10for 8-bit color pixel depth. More preferably, the value of the thresholdfor determining whether or not the subframes are monochromatic isapproximately 5. Again, however, the threshold value for thisdetermination may vary depending on the system parameters of theapparatus.

In yet another embodiment of the analysis performed at processingsegment 108, the hue variances are calculated based on the subdivisionof the subframes into macropixels (smaller subframes). Each subframe forwhich variance of hue is to be computed is subdivided into a smallnumber of areas (subsubframes or macropixels). Instead of calculatingthe hue value for each pixel, the color averages are computed for eachmacropixel as a whole to obtain a single value of hue for each of themacropixels. In Eqs. 11 and 17, therefore, N represents the number ofmacropixels and the mean hue is based on the values for the macropixelsrather than the pixels. This further reduces the computationalcomplexity of the method of the present invention.

In a further embodiment of the analysis performed at segment 108, themean value of hue in each subframe is calculated only for the first fewlines of the subframe. The estimated mean hue value is then used ineither Eq. 11 or Eq. 17 instead of the true mean hue value. This allowsfor real-time single pass image processing without the need to computethe mean values on a first pass and then the variances on a second pass.In the embodiments described above, it is first necessary to determinethe hue for each pixel or macropixel in the subframe in a first pass todetermine the mean hue, and then to calculate the difference between thehue of each pixel and the mean in a second pass, to determine thestandard deviation. In contrast, in this embodiment, by estimating themean hue using only the first few lines in the subframe, the standarddeviation can be calculated upon determining the hue value for each ofthe remaining pixels by determining the difference between each valueand the estimated mean in the same pass.

Since a monochromatic subframe will have approximately the same meanvalue of hue whether a few lines are considered or the whole subframe isconsidered, the driving concept behind the invention is still utilizedwhile significantly reducing the amount of calculation necessary for theimplementation. As a result, this embodiment of the present inventioncan be implemented in real-time systems without a frame memory becauseit operates only on the incoming data stream.

In the example shown in FIG. 2, each subframe marked with an “X” isdetermined to be monochromatic, and is hence excluded from the whitebalancing operation. Subframes having two or more colors, such as theedge regions of the displayed shapes, are not eliminated, as well as thesubframes which are indicated as being substantially grey in color.Since the hue variances for the subframes which are substantially greyin color are undefined, they will not be less than the predeterminedthreshold value for Eqs. 11 and 17 above. However, the three subframeswhich include a very thin grey region and form the right side of thegrey rectangle are eliminated because those subframes are determined tobe substantially monochromatic (blue).

An example of an imaging apparatus 200 incorporating the features of thepresent invention discussed above is shown in FIG. 4, and includes alens system 202 for directing light from an object to be imaged to theimage sensing unit 204 including an image sensor; an analog-to-digitalconverter 206 for converting the image signals received at the imagesensing unit 204 into digital signals; the image/color processing unit208 for performing image correction processes including a circuit 100for performing the automatic white balancing as described above and alsofor performing other processes such as data correction for defectivepixels, color interpolation, sharpness filtering, etc.; an output formatconversion/compression unit 210 for converting the image data into anappropriate file format for being outputted or displayed to the user;and a controller 212 for controlling the operations of the entireimaging apparatus 200. The image sensor in the image sensing unit 204 ispreferably constructed as an integrated circuit which includes pixelsmade of a photosensitive material such as silicon. The image sensor maybe formed as a CMOS sensor and combined with a processor, such as a CPU,digital signal processor or microprocessor, in a single integratedcircuit. Alternatively, the image sensor in the image sensing unit 204may be constructed as a charge coupled device (CCD).

Without being limiting, such an imaging apparatus 200 could include acomputer system, camera system, scanner, machine vision system, vehiclenavigation system, video telephone, surveillance system, auto focussystem, star tracker system, motion detection system, imagestabilization system and data compression system for high-definitiontelevision, all of which can utilize the present invention.

A typical processor system 400, shown in FIG. 5, such as a computersystem, for example, generally comprises a central processing unit (CPU)444 that communicates with an input/output (I/O) device 446 over a bus452. The imaging apparatus 200 communicates with the system over bus 452or a ported connection. The processor system 400 also includes randomaccess memory (RAM) 448, and, in the case of a computer system, mayinclude peripheral devices such as a floppy disk drive 454 and a compactdisk (CD) ROM drive 456 which also communicate with CPU 444 over the bus452.

Although the present invention has been described in relation toparticular embodiments thereof, many other variations and modificationsand other uses will become apparent to those skilled in the art. It ispreferred, therefore, that the present invention be limited not by thespecific disclosure herein, but only by the appended claims.

1. A method for performing a white balance operation on an image,comprising: subdividing an image into a plurality of subframes; for eachsubframe, determining whether or not that subframe is substantiallymonochromatic; eliminating each subframe determined to be substantiallymonochromatic from consideration for white balancing the image; andperforming a white balance operation using the remaining subframes. 2.The method according to claim 1, wherein the determination of whether ornot a subframe is substantially monochromatic comprises: obtaining a huevalue for each pixel in the subframe; calculating a mean hue for thesubframe; calculating a standard deviation of hue variances for thesubframe using sums of the squares of the differences between the huefor each pixel in the subframe and the mean hue; and comparing thestandard deviation with a threshold value.
 3. The method according toclaim 2, wherein the hue value obtained for each pixel is expressed as avalue within a range from 0 to
 360. 4. The method according to claim 2,wherein the hue value obtained for each pixel is expressed as a valuewithin a range from 0 to
 96. 5. The method according to claim 1, whereinthe determination of whether or not a subframe is substantiallymonochromatic comprises: obtaining a hue value for each pixel in thesubframe; calculating a mean hue for the subframe; calculating astandard deviation of the hue variances for the subframe using sums ofthe absolute values of the differences between the hue for each pixel inthe subframe and the mean hue; and comparing the standard deviation witha threshold value.
 6. The method according to claim 5, wherein the huevalue obtained for each pixel is expressed as a value within a rangefrom 0 to
 360. 7. The method according to claim 5, wherein the hue valueobtained for each pixel is expressed as a value within a range from 0 to96.
 8. The method according to claim 1, wherein the determination ofwhether or not a subframe is substantially monochromatic comprises:obtaining a hue value for each pixel in the subframe; calculating a meanhue for the subframe based on the obtained hue values for a subset ofthe lines in the subframe; calculating a standard deviation of the huevariances for the subframe using sums of the squares of the differencesbetween the hue for each pixel in the lines of the subframe not used tocalculate the mean hue and the mean hue; and comparing the standarddeviation with a threshold value.
 9. The method according to claim 8,wherein the hue value obtained for each pixel is expressed as a valuewithin a range from 0 to
 360. 10. The method according to claim 8,wherein the hue value obtained for each pixel is expressed as a valuewithin a range from 0 to
 96. 11. The method according to claim 1,wherein the determination of whether or not a subframe is substantiallymonochromatic comprises: obtaining a hue value for each pixel in thesubframe; calculating a mean hue for the subframe based on the obtainedhue values for a subset of the lines in the subframe; calculating astandard deviation of the hue variances for the subframe using sums ofthe absolute values of the differences between the hue for each pixel inthe lines of the subframe not used to calculate the mean hue and themean hue; and comparing the standard deviation with a threshold value.12. The method according to claim 11, wherein the hue value obtained foreach pixel is expressed as a value within a range from 0 to
 360. 13. Themethod according to claim 11, wherein the hue value obtained for eachpixel is expressed as a value within a range from 0 to
 96. 14. Themethod according to claim 1, further comprising subdividing eachsubframe into a plurality of macropixels, and wherein the determinationof whether or not a subframe is substantially monochromatic comprises:obtaining a hue value for each macropixel in the subframe; calculating amean hue for the subframe based on the obtained macropixel hue values;calculating a standard deviation of the hue variances for the subframeusing sums of the squares of the differences between the hue for eachmacropixel in the subframe and the mean hue; and comparing the standarddeviation with a threshold value.
 15. The method according to claim 14,wherein the hue value obtained for each macropixel is expressed as avalue within a range from 0 to
 360. 16. The method according to claim14, wherein the hue value obtained for each macropixel is expressed as avalue within a range from 0 to
 96. 17. The method according to claim 1,further comprising subdividing each subframe into a plurality ofmacropixels, and wherein the determination of whether or not a subframeis substantially monochromatic comprises: obtaining a hue value for eachmacropixel in the subframe; calculating a mean hue for the subframebased on the obtained macropixel hue values; calculating a standarddeviation of the hue variances for the subframe using sums of theabsolute values of the differences between the hue for each macropixelin the subframe and the mean hue; and comparing the standard deviationwith a threshold value.
 18. The method according to claim 17, whereinthe hue value obtained for each macropixel is expressed as a valuewithin a range from 0 to
 360. 19. The method according to claim 17,wherein the hue value obtained for each pixel is expressed as a valuewithin a range from 0 to
 96. 20. The method according to claim 1,wherein performing the white balance operation comprises: calculating arespective sum of all hue values for each color component in theremaining subframes; determining a weight for each respective sum sothat the three components are equal; and adjusting the hue values foreach pixel in the image according to the determined weight for eachcolor component.
 21. A method for performing a white balance operationon an image, comprising: subdividing an image into a plurality ofsubframes; for each subframe, determining whether or not that subframeis substantially monochromatic; performing a white balance operationonly using subframes which are determined to be not substantiallymonochromatic.
 22. An image processor comprising: a monochrome detectioncircuit which divides an image into a plurality of subframes anddetermines whether or not each subframe is substantially monochromatic;and a white balancing circuit which performs a white balance operationon the image only using subframes which are determined to be notsubstantially monochromatic.
 23. An image processing apparatuscomprising: an image sensing unit for obtaining an image and outputtingan image signal which includes pixel image data for each line of theimage; an image processor for processing the image signal; and acontroller for controlling the image sensing unit and the imageprocessor, and wherein the image processor includes a monochromedetection circuit which divides an image into a plurality of subframesand determines whether or not each subframe is substantiallymonochromatic; and a white balancing circuit which performs a whitebalance operation on the image only using subframes which are determinedto be not substantially monochromatic.
 24. A processing system,comprising: a processor for receiving an processing image data; and animage data generator for supplying image data to the processor, theimage data generator comprising an image sensing unit for obtaining animage and outputting an image signal, an image processor for processingthe image signal, and a controller for controlling the image sensingunit and the image processor, wherein the image processor comprises amonochrome detection circuit which divides an image into a plurality ofsubframes and determines whether or not each subframe is substantiallymonochromatic; and a white balancing circuit which performs a whitebalance operation on the image only using subframes which are determinedto be not substantially monochromatic.